package logic

import (
	"context"
	"encoding/json"
	"github.com/olivere/elastic/v7"
	"server/models"
	"server/proto"
)

func (s *ServerRpc) Range(ctx context.Context, in *proto.RangeReq) (*proto.RangeRes, error) {
	var rr proto.RangeRes
	rr.Data = nil
	quire := elastic.NewRangeQuery("inventory").Gte(10000)
	res, err := models.ShowEs(in.Index, quire)
	marshal, _ := json.Marshal(res)
	if err != nil {
		return &rr, err
	}
	rr.Data = marshal
	return &rr, nil
}
